public class SumNum {
    public static void main(String[] args) {
        int ret = sumNum(1234);
        System.out.println(ret);
        System.out.println(sum);
    }
    public static int sum = 0;
    public static int sumNum(int n) {
        if (n == 0) {
            return 0;
        }
        sum += n%10;
        return n%10 + sumNum(n/10);
    }
}